﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>应用程序文件列表</title>
    <script type="text/javascript" src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">

        function save(id) {
            if (id > 0) {
                $.ajax({
                    url: "/home/changeFileInfo",
                    type: "post",
                    data: "id=" + id + "&fileState=" + $("#fileState" + id).val() + "&descrption=" + $("#descrption" + id).val(),
                    success: function (data) {
                        if (data > 0) {
                            location.href = '@Request.RawUrl';
                        } else {
                            alert("修改失败");
                        }
                    },
                    error: function (request) {
                        alert("请求失败");
                    }
                });
            }
        }
    </script>
</head>
<body>

    <div style="width:80%;margin:0px auto 0px;font-size:12px;">
        <table style="width:100%;">
            <tr>
                <td>文件id</td>
                <td>应用程序id</td>
                <td>文件名称</td>
                <td>文件大小(字节)</td>
                <td>文件hashcode</td>
                <td>文件相对路径</td>
                <td>文件同步操作</td>
                <td>描述</td>
                <td>操作</td>
            </tr>

            @{ 
                if (ViewData["files"] != null)
                {
                    var files = (List<AutoUpdateServer.Models.FileNames>)ViewData["files"];
                    if (files != null && files.Count > 0)
                    {
                        foreach (var item in files)
                        {
                            <tr>
                                <td>@item.id</td>
                                <td>@item.AppID</td>
                                <td>@item.fileName</td>
                                <td>@item.fileLength</td>
                                <td title="@item.fileHashCode">@item.fileHashCode.Substring(0,8)</td>
                                <td>@item.fileRealtiveName</td>
                                <td>
                                    <select id="fileState@(item.id)" name="fileState">
                                        <option value="更新" @{if (item.fileState.Equals("更新")) { <text> selected="selected" </text>} }>更新</option>
                                        <option value="删除" @{if (item.fileState.Equals("删除")) { <text> selected="selected" </text> } }>删除</option>
                                        <option value="保持" @{if (item.fileState.Equals("保持")) { <text> selected="selected" </text> } }>保持</option>
                                    </select>
                                </td>
                                <td><input type="text" name="descrption" id="descrption@(item.id)" value="@item.descrption"/></td>
                                <td><input type="button" value="保存" onclick="save('@item.id')"/> </td>
                            </tr>
                        }
                    }
                }
            }

        </table>
    </div>
</body>
</html>
